package contracts.simpleCodingQuizSubmission

import org.springframework.cloud.contract.spec.Contract

[Contract.make {
    request {
        method("GET")
        url(value(producer("/api/simpleCodingSubmissions/users/5/assignments/1/quizzes/1")
                ,consumer(regex("/api/simpleCodingSubmissions/users/\\d+/assignments/\\d+/quizzes/\\d+"))))
    }
    response {
        status(200)
        body("""
        {
            "id":1,
            "assignmentId":1,
            "quizId":1,
            "userId":1,
            "userAnswer":"https://github.com/tws-online-quiz/java-collection-operator.git",
            "status":2,
            "answerBranch":"master",
            "jobMessage":"正在初始化,正在上传仓库地址,正在检查答案格式",
            "userAnswerZipUrl":"https://s3.cn-north-1.amazonaws.com.cn/quiz-center-files/user-answer/1543385552729-8c03deb9-728e-43b1-b8a8-bc1c42cbfe2b.zip"
        }
        """)
        bodyMatchers {
            jsonPath('$.userAnswerZipUrl', byRegex("[\\s\\S]+"))
            jsonPath('$.jobMessage', byRegex("[\\s\\S]+"))
            jsonPath('$.answerBranch', byRegex("[\\s\\S]+"))
            jsonPath('$.status', byRegex(number()))
            jsonPath('$.userAnswer', byRegex("[\\s\\S]+"))
            jsonPath('$.userId', byRegex(number()))
            jsonPath('$.quizId', byRegex(number()))
            jsonPath('$.assignmentId', byRegex(number()))
            jsonPath('$.id', byRegex(number()))
        }
        headers {
            contentType(applicationJsonUtf8())
        }
    }
}]
